﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Data;
using CM_Classes;


namespace WCF_CM
{
    public class Service1 : IService1
    {
        User user = new User();

        public string AddGroup(string GroupName, int GroupPriority, string GroupDescription, bool GroupDisabled, string SubGroupOf)
        {
            string gn = GroupName;
            int gp = GroupPriority;
            string gd = GroupDescription;
            bool gdis = GroupDisabled;
            string sgo = SubGroupOf;

            return Group.AddGroup(gn, gp, gd, gdis, sgo);
        }

        public string AddUser(int EmpID, string FirstName, string LastName, string UserName, string Password, bool UserDisabled)
        {
            User u = new User();           

            u.EmpID = EmpID;
            u.FirstName = FirstName;
            u.LastName = LastName;
            u.UserName = UserName;
            u.Password = Password;
            u.UserDisabled = UserDisabled;

            return u.AddUser();
        }

        public string DeleteUser(int EmpID)
        {
            User user = new User();

            int empID = EmpID;

            user.EmpID = EmpID;

            return user.DeleteUser();
        }

        public string AddAttrib(string attribName, string dataType, bool attribDisabled, string attribDescription)
        {
            Attrib attrib = new Attrib();
    
            string an = attribName;
            string dt = dataType;
            bool ad = attribDisabled;
            string ads = attribDescription;

            return attrib.AddAttrib(an, dt, ad, ads);
        }

        public string UpdateAttrib(int attribID, string attribName, string dataType, bool attribDisabled, string attribDescription)
        {
            Attrib attrib = new Attrib();


            int ai = attribID;
            string an = attribName;
            string dt = dataType;
            bool ad = attribDisabled;
            string ads = attribDescription;


           
            attrib.AttribName = attribName;
            attrib.DataType = dataType;
            attrib.AttribDisabled = attribDisabled;
            attrib.AttribDescription = attribDescription;


            return attrib.UpdateAttrib(ai,an, dt, ad, ads);
        }

        public string DeleteAttrib(int attribID)
        {
            Attrib attrib = new Attrib();

            int ai = attribID;

            attrib.AttribID = attribID;

            return attrib.DeleteAttrib(ai);
        }

        public string SearchAttrib(string attribName)
        {
            Attrib attrib = new Attrib();

            string ai = attribName;

            attrib.AttribName = attribName;

            return attrib.SearchAttrib(ai);
        }

        public List<User> FindUserByID(int EmpID, string FirstName, string LastName, string UserName, string Password, bool UserDisabled)
        {
            User fid = new User();

            fid.EmpID = EmpID;
            fid.FirstName = FirstName;
            fid.LastName = LastName;
            fid.UserName = UserName;
            fid.Password = Password;
            fid.UserDisabled = UserDisabled;

            return fid.FindUserByID();
        }

        public List<User> FindUserByLastName(int EmpID, string FirstName, string LastName, string UserName, string Password, bool UserDisabled)
        {
            User fln = new User();

            fln.EmpID = EmpID;
            fln.FirstName = FirstName;
            fln.LastName = LastName;
            fln.UserName = UserName;
            fln.Password = Password;
            fln.UserDisabled = UserDisabled;

            return fln.FindUserByLastName();
        }
        public string SaveUser(int EmpID, string FirstName, string LastName, string UserName, string Password, bool UserDisabled)
        {
            User ud = new User();

            ud.EmpID = EmpID;
            ud.FirstName = FirstName;
            ud.LastName = LastName;
            ud.UserName = UserName;
            ud.Password = Password;
            ud.UserDisabled = UserDisabled;

            return ud.SaveUser();
        }

        public string SaveGroup(string GroupName, int GroupPriority, string GroupDescription, bool GroupDisabled, string SubGroupOf)
        {
            Group g = new Group();
            g.GroupName = GroupName;
            g.GroupPriority = GroupPriority;
            g.GroupDescription = GroupDescription;
            g.GroupDisabled = GroupDisabled;
            g.SubGroupOf = SubGroupOf;

            return g.SaveGroup();
        }

        public string DeleteUser(int EmpID, string FirstName, string LastName, string UserName, string Password, bool UserDisabled)
        {
            User d = new User();

            d.EmpID = EmpID;
            d.FirstName = FirstName;
            d.LastName = LastName;
            d.UserName = UserName;
            d.Password = Password;
            d.UserDisabled = UserDisabled;

            return d.DeleteUser();
        }


        
        public List<UserGroup> GetUserGroups()
        {
            UserGroup ug = new UserGroup();

            return ug.GetUserGroups();
        }

        public List<GroupAttrib> GetGroupAttribs()
        {
           GroupAttrib ga = new GroupAttrib();

            return ga.GetGroupAttribs();
        }

        public List<Attrib> GetAllAttrib()
        {
            Attrib attrib = new Attrib();

            return attrib.GetAllAttrib();
        }

        public List<User> GetUsers()
        {
            User user = new User();

            return user.GetUsers();
        }

       



    }
}
